package healththink

class MobileService {

    boolean detect(request) {
	 
	   def device = request.getAttribute('currentDevice')
	 
	   boolean detected = device.isMobile()
	 
	   if (detected) {
	 
	     def userAgent = request.getHeader('User-Agent')
	 
	     if (userAgent?.contains('iPad')) { // skip iPads
	 
	        detected = false
	 
	     } else if (userAgent?.contains('Android') && !userAgent?.contains('Mobile')) {
	 
	        // and android tables
	 
	        detected = false
	 
	     }
	 
	   }
	 
	   detected
	 
    }
}
